home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Think Class Libraries / WASTE TCL 1.8 / WASTEEdit / CEditPane.cp < prev    next >
Encoding:
Text File  |  1995-07-09  |  2.5 KB  |  109 lines  |  [TEXT/KAHL]

  1. /******************************************************************************
  2.     CEditPane.c
  3.     
  4.     Methods for a text editing pane.
  5.         
  6.     Copyright © 1989 Symantec Corporation. All rights reserved.
  7.  
  8.  ******************************************************************************/
  9.  
  10.  
  11. #include "CEditPane.h"
  12. #include "Commands.h"
  13. #include "CDocument.h"
  14. #include "CBartender.h"
  15. #include "Constants.h"
  16.  
  17. extern    CBartender    *gBartender;
  18.  
  19. void CEditPane::IEditPane(CView *anEnclosure, CBureaucrat *aSupervisor)
  20.  
  21. {
  22.     Rect    margin;
  23.  
  24.     CWASTEText::IWASTEText(anEnclosure, aSupervisor, 1, 1, 0, 0,
  25.                         sizELASTIC, sizELASTIC, -1);
  26.     FitToEnclosure(TRUE, TRUE);
  27.  
  28.         /**
  29.          **    Give the edit pane a little margin.
  30.          **    Each element of the margin rectangle
  31.          **    specifies by how much to change that
  32.          **    edge. Positive values are down and to
  33.          **    right, negative values are up and to
  34.          **    the left.
  35.          **
  36.          **/
  37.  
  38.     SetRect(&margin, 3, 3, -3, -3); // margins increased for drag and drop
  39.     ChangeSize(&margin, FALSE);
  40. #ifdef WASTE11
  41.     InstallDragHandlers(); // to enable drag and drop
  42. #endif
  43. }
  44.  
  45. void CEditPane::DoCommand(long theCommand)
  46.  
  47. {
  48.     
  49.     if (((theCommand == cmdPaste) || (theCommand == cmdCut)) && 
  50.         !((CDocument *)itsSupervisor)->dirty) {
  51.         
  52.         ((CDocument *)itsSupervisor)->dirty = TRUE;
  53.         gBartender->EnableCmd(cmdSave);
  54.         gBartender->EnableCmd(cmdSaveAs);
  55.     }
  56.  
  57.     inherited::DoCommand(theCommand);
  58. }
  59.  
  60.  
  61. void CEditPane::DoKeyDown(char theChar, Byte keyCode, EventRecord *macEvent)
  62.  
  63. {
  64.     
  65.     inherited::DoKeyDown(theChar, keyCode, macEvent);
  66.  
  67.     switch (keyCode) {
  68.     
  69.         case KeyHome:
  70.         case KeyEnd:
  71.         case KeyPageUp:
  72.         case KeyPageDown:
  73.             break;
  74.             
  75.         default:    
  76.             if (!((CDocument *)itsSupervisor)->dirty) {
  77.                 ((CDocument *)itsSupervisor)->dirty = TRUE;
  78.                 gBartender->EnableCmd(cmdSave);
  79.                 gBartender->EnableCmd(cmdSaveAs);
  80.             }
  81.             break;
  82.     }
  83. }
  84.  
  85.  
  86. void CEditPane::DoAutoKey(char theChar, Byte keyCode, EventRecord *macEvent)
  87.  
  88. {
  89.     
  90.     inherited::DoAutoKey(theChar, keyCode, macEvent);
  91.  
  92.     switch (keyCode) {
  93.     
  94.         case KeyHome:
  95.         case KeyEnd:
  96.         case KeyPageUp:
  97.         case KeyPageDown:
  98.             break;
  99.             
  100.         default:    
  101.             if (!((CDocument *)itsSupervisor)->dirty) {
  102.                 ((CDocument *)itsSupervisor)->dirty = TRUE;
  103.                 gBartender->EnableCmd(cmdSave);
  104.                 gBartender->EnableCmd(cmdSaveAs);
  105.             }
  106.             break;
  107.     }
  108. }
  109.